package com.ksyun.whgc.heruiming.work2;

import java.lang.reflect.Field;
import java.util.List;

/**
 * 2.定义工具类输出集合对象:集合输出时根据属性的标注输出属性字段名;(20分)
 */
public  class PrintUtil {

    public static void printStuList(List<Student> list) {
        Class<Student> studentClass = Student.class;
        Field[] declaredFields = studentClass.getDeclaredFields();
        System.out.print("属性字段名\t");
        for (Field declaredField : declaredFields) {
            myAnnotation annotation = declaredField.getAnnotation(myAnnotation.class);
            String value = annotation.value();
            System.out.print(value + "\t\t");
        }
        System.out.println();
        for (Student student : list) {
            System.out.print("\t\t\t"+student.getName()+"\t\t\t"+student.getAge()+"\t\t"+student.getAddress()+"\t"+student.getBirthday());
            System.out.println();
        }
    }
}
